package photorganizer.common.util;

import java.util.LinkedHashMap;
import java.util.Map.Entry;

public class LRUMap<K, V> extends LinkedHashMap<K, V> {

	private static final long serialVersionUID = 3065626096558035218L;

	private final int capacity;

	public LRUMap(int capacity) {
		super((int) Math.ceil(capacity / 0.75f) + 1, 0.75f, true);
		this.capacity = capacity;
	}

	@Override
	@SuppressWarnings("unused")
	protected boolean removeEldestEntry(Entry<K, V> eldest) {
		return size() > capacity;
	}

}
